# 导包
from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep

# 实例化浏览器
driver = webdriver.Edge()
# 网址
my_url = 'https://www.leafground.com/alert.xhtml'
# 打开网页
driver.get(my_url)
# 窗口最大化
driver.maximize_window()

# Alert (Prompt Dialog)
driver.find_element(By.XPATH, '//*[@id="j_idt88:j_idt104"]/span[2]').click()
alert = driver.switch_to.alert
alert.send_keys('这是一个Alert (Prompt Dialog)测试')
# 点击确定
alert.accept()
# 点击关闭
# alert.dismiss()

# 等待3秒
sleep(3)
# 关闭实例化浏览器
driver.quit()